package com.mdd.admin.controller.staff;

import com.mdd.admin.config.aop.Log;
import com.mdd.admin.service.staff.IStaffService;
import com.mdd.admin.validate.staff.StaffParam;
import com.mdd.admin.validate.staff.StaffStatusParam;
import com.mdd.admin.vo.staff.StaffDetailVo;
import com.mdd.admin.vo.staff.StaffListVo;
import com.mdd.admin.vo.staff.StaffPageParam;
import com.mdd.common.core.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 师傅管理
 */
@Api(tags = "师傅管理")
@RestController
@RequestMapping("api/staff")
public class StaffController {

    @Resource
    IStaffService iStaffService;

    /**
     * 师傅列表
     *
     * @param params 搜索参数
     * @return Object
     */
    @ApiOperation(value = "师傅管理 - 分页列表")
    @PostMapping("/list")
    public PageResult<StaffListVo> list(@RequestBody StaffPageParam params) {
        return iStaffService.list(params);
    }

    /**
     * 师傅详情
     *
     * @param id 主键ID
     * @return Object
     */
    @ApiOperation(value = "师傅管理 - 师傅详情")
    @GetMapping("/detail")
    public StaffDetailVo detail(@RequestParam("id") Long id) {
        return iStaffService.detail(id);
    }

    /**
     * 师傅新增
     *
     * @param staffParam 参数
     * @return Object
     */
    @ApiOperation(value = "师傅管理 - 师傅新增")
    @Log(title = "师傅新增")
    @PostMapping("/add")
    public void add(@Validated(value = StaffParam.create.class) @RequestBody StaffParam staffParam) {
        iStaffService.add(staffParam);
    }

    /**
     * 师傅编辑
     *
     * @param staffParam 参数
     * @return Object
     */
    @ApiOperation(value = "师傅管理 - 师傅编辑")
    @Log(title = "师傅编辑")
    @PostMapping("/edit")
    public void edit(@Validated(value = StaffParam.update.class) @RequestBody StaffParam staffParam) {
        iStaffService.edit(staffParam);
    }

    /**
     * 师傅删除
     *
     * @return Object
     */
    @ApiOperation(value = "师傅管理 - 师傅删除")
    @Log(title = "师傅删除")
    @GetMapping("/del")
    public void del(@RequestParam("id") Long id) {
        iStaffService.del(id);
    }

    /**
     * 师傅删除
     *
     * @return Object
     */
    @ApiOperation(value = "师傅管理 - 师傅状态变更")
    @Log(title = "师傅启动/禁用")
    @PostMapping("/status")
    public void status(@RequestBody StaffStatusParam statusParam) {
        iStaffService.status(statusParam);
    }

    /**
     * 师傅流水
     * @param params
     * @return
     */
    @ApiOperation(value = "师傅流水")
    @PostMapping("/water")
    public PageResult<StaffListVo> water(@RequestBody StaffPageParam params) {
        return iStaffService.water(params);
    }
}
